#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

class Solution {
public:
    vector<vector<int>> fourSum(vector<int>& nums, int target) {
    	vector<vector<int>> ans;
    	sort(nums.begin(), nums.end());
        int _d = nums.size() - 1;
        for(int i = 0; i < nums.size() && i < _d; i++){
        	if(i > 0 && nums[i] == nums[i - 1])continue;
        	for(int j = i + 1; j < nums.size() && j < _d; j++){
        		if(j > i + 1 && nums[j] == nums[j - 1])continue;
        		_d = nums.size() - 1;
        		for(int l = j + 1; l < nums.size() && l < _d;){
        			if(l > j + 1 && nums[l] == nums[l - 1]){
        				l++;
						continue;
					}
        			if(nums[i] + nums[j] + nums[l] + nums[_d] > target)_d--;
        			else if(nums[i] + nums[j] + nums[l] + nums[_d] < target)l++;
        			else{
        				ans.push_back(vector<int>({nums[i], nums[j], nums[l++], nums[_d--]}));
					}
				}
			}
		}
		return ans;
    }
};

int main(){
	
}
